<?php
include_once( 'initlite.php' );
if($_POST["postid"] && ($_POST["comment"] || $_POST["replay"])){
	$statePostId = trim($_POST["postid"]);
	if($_POST["replay"]){
		$statePostComment = $c->reply($statePostId, trim($_POST["comment"]), trim($_POST["replay"]));
	}
	else{
		$statePostComment = $c->send_comment($statePostId, trim($_POST["comment"]));
	}
	if($statePostComment["error_code"]){
		echo $statePostComment["error_code"];
	}
	else{
		$statePostCommentText = format($statePostComment["text"]);
		$statePostCommentUserName = $statePostComment["user"]["screen_name"];
		$statePostCommentUserId = $statePostComment["user"]["id"];
		$statePostCommentUserName = $statePostCommentUserName?$statePostCommentUserName:$statePostCommentUserId;
		for($j=0; $j<count($faces); $j++){
			$statePostCommentText = str_replace("[".$faces[$j]."]","<img src='/images/faces/".$j.".gif' />",$statePostCommentText);
		}
?>
<div class="statePostComment" id="comment_<?php echo $statePostComment["id"]; ?>">
<div>
<div class="statePostCommentHead"><img style="width: 30px; height: 30px;" src="<?php echo $statePostComment["user"]["profile_image_url"]; ?>" /></div>
<div class="statePostCommentPost">
<div><span class="statePostCommentUserName"><a href="/user/<?php echo $statePostCommentUserName; ?>"><?php echo $statePostCommentUserName; ?></a></span> - <?php echo $statePostCommentText; ?></div>
<div class="statePostCommentTime"><?php echo formatTime($statePostComment["created_at"]); ?> - <?php if($_GET["postpage"]){ ?><span class="commentsReplayAction"><a href="##" onclick="setElCenter(document.getElementById('replaybox-<?php echo $statePostId; ?>'));replayComment('replaybox-<?php echo $statePostId; ?>','<?php echo $statePostCommentUserName; ?>','commentid-<?php echo $statePostId; ?>','<?php echo $statePostComment["id"]; ?>');document.getElementById('commentbox-<?php echo $statePostId; ?>').focus();rollto('comments-<?php echo $statePostId; ?>';return false;)"><?php }else{ ?><a href="##" onclick="replayComment('replaybox-<?php echo $statePostId; ?>','<?php echo $statePostCommentUserName; ?>','commentid-<?php echo $statePostId; ?>','<?php echo $statePostComment["id"]; ?>');document.getElementById('commentbox-<?php echo $statePostId; ?>').focus();return false;"><?php } ?>回复</a> - <a href="##" onclick="delComment(<?php echo $statePostComment["id"]; ?>);return false;">删除</a></span></div>
</div>
<div class="floatClear"></div>
</div>
</div>
<?php
	}
}
?>